//
//  FIGoodsDetailsHeader.m
//  cherryproduct
//
//  Created by zou shigang on 14/9/6.
//  Copyright (c) 2014年 cherry. All rights reserved.
//

#import "FIGoodsDetailsHeader.h"

@implementation FIGoodsDetailsHeader

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        // 初始化时加载collectionCell.xib文件
        NSArray * arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"FIGoodsDetailsHeader" owner:self options:nil];
        // 如果路径不存在，return nil
        if(arrayOfViews.count < 1){return nil;}
        // 如果xib中view不属于UICollectionViewCell类，return nil
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionReusableView class]]) {
            return nil;
        }
        // 加载nib
        self = [arrayOfViews objectAtIndex:0];
        
        self.scrollview_base.delegate=self;
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
{
    CGFloat pageWidth = scrollView.frame.size.width;
    int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    self.page_control.currentPage = page;
}

@end













